package com.rupertjones.globalcron.client;

import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class GlobalCronClient {
    private static final Logger LOG = Logger.getLogger(GlobalCronClient.class);
    public static final int TEN_SECONDS = 10000;

    public static void main(String[] args) {
        GlobalCronClient app = new GlobalCronClient();
        app.run();
    }

    private void run() {
        Thread.currentThread().setName("GlobalCronClient");
        LOG.info("Starting Global Cron Client Process...");
        new ClassPathXmlApplicationContext("conf/global-cron-client-config.xml");
        boolean interrupted = false;
        try {
            LOG.info("Global Cron Client Process running.");
            while (!interrupted) {
                Thread.sleep(TEN_SECONDS);
                LOG.trace("Global Cron Client Process pulse.");
            }
            LOG.info("Global Cron Client Process stopped.");
        } catch (InterruptedException inte) {
            LOG.error(inte);
        }
    }
}
